<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
        <meta name="author" content="Adam Freeman"/>
        <meta name="description" content="A simple example"/>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
        <style title="core styles">
            p {
                padding: 7px !important;
            }
            table {border: thin solid black; border-collapse: collapse;
                    margin: 5px; float: left;}
            td {padding: 2px;}
        </style>
    </head>
    <body>
        <p id="block1">There are lots of different kinds of fruit - there are over
            500 varieties of banana alone. By the time we add the countless types of
            apples, oranges, and other well-known fruit, we are faced with thousands of
            choices.
        </p>
        <div id="placeholder"></div>
        <script>
            var placeholder = document.getElementById("placeholder");
            displayStyles();
            
            function displayStyles() {
                var newElem = document.createElement("table");
                newElem.setAttribute("border", "1");                                    
                
                var targetElem = document.getElementById("block1");
                var style = document.defaultView.getComputedStyle(targetElem);                                
                addRow(newElem, "Property Count", style.length);
                addRow(newElem, "margin-top", style.getPropertyValue("margin-top"));
                addRow(newElem, "font-size", style.getPropertyValue("font-size"));
                addRow(newElem, "font-family", style.getPropertyValue("font-family"));
                
                placeholder.appendChild(newElem);                
            }

            function addRow(elem, header, value) {
                elem.innerHTML += "<tr><td>" + header + ":</td><td>"
                    +  value + "</td></tr>";
            }
        </script>
    </body>
</html>
